#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include "stm32f10x.h"
/*时间戳转换为标准时间*/
typedef struct times
{
	u8 Year;
	u8 Mon;
	u8 Day;
	u8 Hour;
	u8 Min;
	u8 Second;
}Times;

/*标准时间转换为时间戳*/
u32 standard_to_stamp(u8 *dataTime)
{
	struct tm stm;

     u32 result = 0;
	memset(&stm,0,sizeof(stm));
	stm.tm_year=2000 + dataTime[5]-1900;
	stm.tm_mon=dataTime[4] - 1;
	stm.tm_mday=dataTime[3];
	stm.tm_hour=dataTime[2];
	stm.tm_min=dataTime[1];
	stm.tm_sec=dataTime[0];
    stm.tm_isdst = -1;
    result = mktime(&stm);
	// printf("解析后的时间是%d-%d-%d %d:%d:%d\n", iY, iM, iD, iH, iMin, iS);
    // strftime(buffer, sizeof(buffer), "%c", &stm );
    // SPrint(buffer);
    // WPrint("\r\n res: %d",result);
	return result;

}


void stamp_to_standard(int stampTime,u8 * result)
{
        //  char buffer[80];
	time_t tick = (time_t)stampTime;
	struct tm tm;
	tm = *localtime(&tick);

	result[5] = tm.tm_year - 100;
	result[4] = tm.tm_mon + 1;
	result[3] = tm.tm_mday;
	result[2] = tm.tm_hour;
	result[1] = tm.tm_min;
	result[0] = tm.tm_sec;
    //  strftime(buffer, sizeof(buffer), "%c", &tm );
    // SPrint(buffer);

}

